
#ifndef HAL_ADC_H
#define HAL_ADC_H

#include "hal_types.h"
#include "adc_lld.h"

/*****************ADC0为10bit adc******************/
/*****************ADC1为12bit adc******************/

#define ADC_ADCLKSEL_0          0U
#define ADC_ADCLKSEL_1          1U
#define ADC_MODE_SCAN           1U
#define ADC_MODE_ONESHOT        0U
#define ADC_OWREN               1U
#define ADC_ACKO                1U
#define ADC_PWDN                0U
#define ADC_PWON                1U
#define ADC_RIGHTALIGNED        0U

typedef enum
{
	ADC_SINGLE = 0,
	ADC_CONTINU = 1
}adc_mode_en;

typedef enum
{
	ADC_10BIT = 0,
	ADC_12BIT = 1
}adc_bit_en;

typedef enum
{
	ADC_CONVERT_DONE = 0 ,
	ADC_CONVERTTING = 1,
	ADC_UNSTART	= 2,
	ADC_UNINIT = 3,
	ADC_ARRAY_CONVERT_DONE = 4
}adc_status_en;

typedef enum
{
	ADC_CHANNEL_P0 = 0,
	ADC_CHANNEL_P1 = 1,
	ADC_CHANNEL_P2 = 2,
	ADC_CHANNEL_P3 = 3,
	ADC_CHANNEL_P4 = 4,
	ADC_CHANNEL_P5 = 5,
	ADC_CHANNEL_P6 = 6,
	ADC_CHANNEL_P7 = 7,
	ADC_CHANNEL_P8 = 8,
	ADC_CHANNEL_P9 = 9,
	ADC_CHANNEL_P10 = 10,
	ADC_CHANNEL_P11 = 11,
	ADC_CHANNEL_P12 = 12,
	ADC_CHANNEL_P13 = 13,
	ADC_CHANNEL_P14 = 14,
	ADC_CHANNEL_P15 = 15,
	ADC_CHANNEL_S0 = 32,
	ADC_CHANNEL_S1 = 33,
	ADC_CHANNEL_S2 = 34,
	ADC_CHANNEL_S3 = 35,
	ADC_CHANNEL_S4 = 36,
	ADC_CHANNEL_S5 = 37,
	ADC_CHANNEL_S6 = 38,
	ADC_CHANNEL_S7 = 39,
	ADC_CHANNEL_S8 = 40,
	ADC_CHANNEL_S9 = 41,
	ADC_CHANNEL_S10 = 42,
	ADC_CHANNEL_S11 = 43,
	ADC_CHANNEL_S12 = 44,
	ADC_CHANNEL_S13 = 45,
	ADC_CHANNEL_S14 = 46,
	ADC_CHANNEL_S15 = 47
}adc_channel_en;

typedef enum
{
	ADC_TRIG_TIM_1 = 0,
	ADC_TRIG_TIM_2 = 1,
	ADC_TRIG_PWM = 2,
	ADC_TRIG_SW
}adc_trig_type_en;

typedef enum
{
	
}adc_irq_type_en;

typedef void(* adc_cbk)(void);

void hal_adc_hard_triger(adc_channel_en channel ,adc_trig_type_en trig_type);
adc_status_en hal_adc_status(void);
uint32_t hal_adc_result(adc_channel_en channel , adc_bit_en bit);
void hal_adc_result_array(adc_channel_en , uint32_t array , uint8_t len);
void hal_adc_init(adc_channel_en channel , adc_mode_en mode ,adc_bit_en bit , adc_trig_type_en trig_type,enabled_en en);
void hal_adc_bit(adc_channel_en channel , uint8_t bit);
void hal_adc_enabled(adc_channel_en channel , enabled_en en);
void hal_adc_multi_init(uint32_t *array , uint8_t len);
void hal_adc_conver_cbk(adc_channel_en channel , adc_cbk cbk);
void hal_adc_irq_config(adc_channel_en channel , adc_irq_type_en irq_type , uint8_t priorty , enabled_en en);
void hal_adc_start_convert(void);
void hal_adc_stop_convert(void);

#endif 
